package com.yanqu.road.server.manager.union.activitygroup;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.enums.eActivityType;
import com.yanqu.road.entity.union.activitygroup.UnionActivityGroupUnion;
import com.yanqu.road.server.manager.activity.ActivityInfoMgr;
import com.yanqu.road.server.manager.activity.hanghai.CrossHangHaiActivity;
import com.yanqu.road.server.manager.activity.hanghai.CrossHangHaiMgr;
import com.yanqu.road.server.manager.activity.suitang.CrossSuiTangMgr;
import com.yanqu.road.server.manager.activity.suitang.activity.CrossSuiTangActivity;

public class UnionActivityGroupUpdateUnionLogic {

    public static void onUnionUpdate(UnionActivityGroupUnion union) {
        ActivityInfo activityInfo = ActivityInfoMgr.getActivityInfo(union.getActivityId());
        if (activityInfo == null) {
            return;
        }
        if (activityInfo.getType() == eActivityType.HangHaiActivity.getValue()) {
            hangHaiUnionUpdate(union);
        }
        if (activityInfo.getType() == eActivityType.SuiTang.getValue()) {
            suiTangUnionUpdate(union);
        }
    }

    private static void hangHaiUnionUpdate(UnionActivityGroupUnion union) {
        CrossHangHaiActivity activity = CrossHangHaiMgr.getActivity(union.getActivityId(), union.getGroupId());
        if (activity != null) {
            activity.unionUpdate(union);
        }
    }

    private static void suiTangUnionUpdate(UnionActivityGroupUnion union) {
        CrossSuiTangActivity activity = CrossSuiTangMgr.getActivity(union.getActivityId(), union.getGroupId());
        if (activity != null) {
            activity.unionUpdate(union);
        }
    }

}
